import { Body, Controller, Get, Post, Query, Req, UseGuards } from '@nestjs/common';
import { Request } from 'express';
import { OrderService } from 'src/order/order.service';
import { ProductService } from 'src/product/product.service';
import { PayService } from './pay.service';
import { AuthGuard } from '@nestjs/passport';


@UseGuards(AuthGuard('jwt'))
@Controller('pay')
export class PayController {
    constructor(
        private readonly payService: PayService,
        private readonly orderService: OrderService,
    ) { }

    // PC端支付
    @Post()
    index(@Body() body: any, @Req() req: Request) {
        body.user = req.user;
        return this.payService.index(body, this.orderService)
    }

    //小程序下单
    @Get('applets')
    placeAnOrder(@Query() query: any, @Req() req: Request) {
        query.user = req.user;
        return this.payService.placeAnOrder(query, this.orderService);
    }
}
